package com.hphs.controller;

import com.hphs.dto.ResponseDTO;
import com.hphs.model.VideoQuery;
import com.hphs.model.Videos;
import com.hphs.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/videos")
@CrossOrigin
public class CarController {
    @Autowired
    private CarService carService;

    @GetMapping
    public List<Videos> select(VideoQuery query){
        List<Videos> select = carService.select(query);
//        int a=1/0;
        return select;
    }

//    @GetMapping
//    public ResponseDTO select(VideoQuery query){
//        List<Videos> select = carService.select(query);
//        return ResponseDTO.success(select);
//    }

    @PostMapping
    public int insert(@RequestBody Videos videos){
        return  carService.insert(videos);
    }
    @PutMapping
    public int update(@RequestBody Videos videos){
        return carService.update(videos);
    }

    @DeleteMapping
    public int delete(Integer id){
        return carService.delete(id);
    }

}
